﻿#region Using Statements
using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;

#endregion

#region COPYRIGHT

/*
    Copyright (c) 2007, 2008, 2009, 2010 
        Roland Rosenkranz (Glatzemann@email.de)
*/

#endregion

#region LICENSE

/*
    This file is part of starLiGHT.Input.

    starLiGHT.Input is free software: you can redistribute it and/or modify
    it under the terms of the GNU Lesser General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    starLiGHT.Input is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public License
    along with starLiGHT.Input.  If not, see <http://www.gnu.org/licenses/>.

    
    ADDITIONAL (commercial) LICENSES for starLiGHT.Input are available on request.
*/

#endregion

#region Version Stuff
// **************[ starLiGHT.Engine SVN ]**********************
// * $Rev:: 1496                  $:  Revision of last commit *
// * $Author:: glatzemann         $:  Author of last commit   *
// * $Date:: 2010-10-11 09:38:05 #$:  Date of last commit     *
// ************************************************************
#endregion

namespace starLiGHT.Input
{
    public class ControlSchemeButton : IEquatable<ControlSchemeButton>
    {
#region Member Variables
        protected internal List<IAnalogControl> analogControls;
        protected internal List<IDigitalControl> digitalControls;

        public bool autoRepeat;
#endregion

#region Constructors

        private ControlSchemeButton()
        {
            analogControls = new List<IAnalogControl>();
            digitalControls = new List<IDigitalControl>();
        }

        public ControlSchemeButton(bool repeat, IAnalogControl analogControl)
            : this()
        {
            this.autoRepeat = repeat;
            this.analogControls.Add(analogControl);
        }

        public ControlSchemeButton(bool repeat, IDigitalControl digitalControl)
            : this()
        {
            this.autoRepeat = repeat;
            this.digitalControls.Add(digitalControl);
        }

        public ControlSchemeButton(bool repeat, IAnalogControl analogControl, IDigitalControl digitalControl)
            : this()
        {
            this.autoRepeat = repeat;
            this.analogControls.Add(analogControl);
            this.digitalControls.Add(digitalControl);
        }

        public ControlSchemeButton(bool repeat, IEnumerable<IAnalogControl> analogControls)
            : this()
        {
            this.autoRepeat = repeat;
            this.analogControls.AddRange(analogControls);
        }

        public ControlSchemeButton(bool repeat, IEnumerable<IDigitalControl> digitalControls)
            : this()
        {
            this.autoRepeat = repeat;
            this.digitalControls.AddRange(digitalControls);
        }

        public ControlSchemeButton(bool repeat, IEnumerable<IAnalogControl> analogControls, IEnumerable<IDigitalControl> digitalControls)
            : this()
        {
            this.autoRepeat = repeat;
            this.analogControls.AddRange(analogControls);
            this.digitalControls.AddRange(digitalControls);
        }

#endregion

        public bool Equals(ControlSchemeButton other)
        {
            return (analogControls.Equals(other.analogControls) && digitalControls.Equals(other.digitalControls));
        }

        public static bool operator == (ControlSchemeButton left, ControlSchemeButton right)
        {
            return (left.Equals(right));
        }

        public static bool operator !=(ControlSchemeButton left, ControlSchemeButton right)
        {
            return (!left.Equals(right));
        }

        public override int GetHashCode()
        {
            return analogControls.GetHashCode() | digitalControls.GetHashCode();
        }

        public override bool Equals(object obj)
        {
            return this.Equals((ControlSchemeButton)obj);
        }
    }
}
